layui.use(['element','layer'], function() {
    var layer=layui.layer;
    function messageLoad(){
        //动态菜单
        layui.jquery.ajax({
            url: "/friend/friendList",
            method: 'POST',
            data:{
                name:$("#name").val()
            },
            success: function(res) {
                var html = "";
                if (res!=""){
                    for(var i = 0; i < res.length; i++) {
                        var strli ="";
                        strli+="<div class=\"layui-col-md6\"><div class=\"layui-panel\"><div style=\"padding: 30px;text-align: center;\"><a id=\"user_"+res[i].id+"\" href=\"javascript:;\" onclick='userClick("+res[i].id+");'>"+res[i].userName+"</a></div></div></div>";
                        html = html + strli;
                    }
                }else {
                    html+="<div style=\"text-align: center;\">暂无用户或已添加为好友</div>";
                }
                layui.jquery("#queryFriend").html(html);
                layui.element.init(); //一定初始化一次
            }
        });
    };
    window.setInterval(messageLoad, 100);
});